package org.example.design.designmode.prototype;
/**
 * @Author:         songyafei
 * @Package:        com.des.design.designMode.prototype
 * @ClassName:      user
 * @Description:     用户类
 * @Param
 * @Exception
 * @CreateDate:     2020/5/11 21:24
 * @UpdateRemark:   The modified content
 * @Version:        1.0
 * @Return :
 **/

public class User  implements  UserClone{

        private Integer id;

        private String idCard;

        private String name;

        private Integer age;

        private Long ismale;




        /**
         * @Author:         songyafei
         * @Package:        com.des.design.designMode.prototype
         * @ClassName:      user
         * @Description:    传统业务中对象的复制创建需要我们创建实例在一个个set进行赋值
         * @Param           [u]
         * @Exception
         * @CreateDate:     2020/5/11 21:28
         * @UpdateRemark:   The modified content
         * @Version:        1.0
         * @Return :        com.des.design.designMode.prototype.user
         **/

        public User getClone(User u){
            User user = new User();
            user.setAge(u.getAge());
            user.setId(u.getId());
            user.setName(u.getName());
            return user;
        }
        //自定义泛型克隆方法
    @Override
    public Object getClone() {
        User user = new User();
        user.setAge(this.getAge());
        user.setId(this.getId());
        user.setName(this.getName());
        return user;
    }


    //通过java 自带的克隆类实现它重写克隆方法
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }





    public Integer getId() {
            return id;
        }

        public void setId(Integer id) {
            this.id = id;
        }

        public String getIdCard() {
            return idCard;
        }

        public void setIdCard(String idCard) {
            this.idCard = idCard == null ? null : idCard.trim();
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name == null ? null : name.trim();
        }

        public Integer getAge() {
            return age;
        }

        public void setAge(Integer age) {
            this.age = age;
        }

        public Long getIsmale() {
            return ismale;
        }

        public void setIsmale(Long ismale) {
            this.ismale = ismale;
        }



}
